#ifndef __SOC_GPIO_H__
#define __SOC_GPIO_H__

#include "iperipheral.h"

/// @brief 
class SOC_Gpio : public IPeripheral
{
public:
    explicit SOC_Gpio();
    explicit SOC_Gpio(GpioPort port, uint8_t pin);
    explicit SOC_Gpio(const GpioPortPin &portPin);
    virtual ~SOC_Gpio();

public:
    void Toggle();
    void Write(int val);
    void Set();
    void Clear();
    int Read();

    //gpio 提供全局调用, 需要在子类实现
public:
    static void Toggle(GpioPort port, uint8_t pin);
    static void Write(GpioPort port, uint8_t pin, int val);
    static void Set(GpioPort port, uint8_t pin);
    static void Clear(GpioPort port, uint8_t pin);
    static int Read(GpioPort port, uint8_t pin);

    static void Toggle(const GpioPortPin &portPin);
    static void Write(const GpioPortPin &portPin, int val);
    static void Set(const GpioPortPin &portPin);
    static void Clear(const GpioPortPin &portPin);
    static int Read(const GpioPortPin &portPin);

private:
    GpioPort m_port = GpioPort::None;
    uint8_t m_pin;
};

#endif // __SOC_GPIO_H__
